<table border="0" cellpadding="0" cellspacing="0" class="member-grid">
  <thead>
    <tr>
      <th></th>
      <th><{t}>金额<{/t}></th>
      <th><{t}>订单状态<{/t}></th>
      <th><{t}>支付方式<{/t}></th>
	  <th><{t}>汇款单<{/t}></th>
      <th><{t}>操作<{/t}></th>
    </tr>
  </thead>
  <{if $orders}>
  <{foreach from=$orders item=order name=orders key="key"}>
  <tbody class="<{if !$is_orders}>fold<{else}>unfold<{/if}><{if $smarty.foreach.orders.iteration == 1}> first<{/if}>">
  <{if $order.pay_status == '1' && $alphapay.number == $order.order_id}>
	<tr class="bg-success">
		<td colspan='6' style="padding: 10px 20px; height: auto;">
			<p style="margin: 0; padding: 0;"><b>Ваш заказ №<{$alphapay.number}> успешно оплачен на сумму <{$alphapay.amount}> руб.</b></p>
		</td>
	</tr>
	<{/if}>   
	
    <tr>
        <td colspan="6" style=" padding:5px 10px;border-left: 1px solid #eee;border-right: 1px solid #eee;border-bottom: 1px solid #eee;">
              <{if $order.pre_order == 'true'}>
              <{t}>订单号<{/t}><a href="<{link app=b2c ctl=site_member act=orderdetail arg0=$order.order_id arg1=$archive}>" style=" margin-left:10px;"><{$order.order_id}></a>
              <{else}>
              <{t}>订单号<{/t}><a href="<{link app=b2c ctl=site_member act=orderdetail arg0=$order.order_id arg1=$archive}>" style=" margin-left:10px;"><{$order.order_id}></a>
              <{/if}>              
              <span class="datetime" style="margin-left:20px;"><{$order.createtime|cdate:FDATE_STIME}></span>
        </td>
    </tr>
    <tr>
      <td class="order" style="border-left: 1px solid #eee;text-align: left;"><span class="handle action-view-goods">[<{t}>商品<{/t}> <{$order.nums}>]<i class="icon arrow-down">&#x36;</i><i class="icon arrow-up">&#x37;</i></span></td>
      <td class="price" style="border-left: 1px solid #eee;border-bottom: 1px solid #eee;"><{$order.cur_amount|cur_odr:$order.currency:false:true}></td>
   <td class="status" style="border-left: 1px solid #eee;border-bottom: 1px solid #eee;">
        <{switch from=$order.status}>
        <{case value='finish'}><{t}>已完成<{/t}>
        <{case value='dead'}><{t}>已作废<{/t}>
        <{case}>
        <{switch from=$order.pay_status}>
        <{case value='1'}><{t}>已付款<{/t}>
        <{switch from=$order.ship_status}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{case}><{t}>[正在备货]<{/t}>
        <{/switch}>
        <{case value='2'}><{t}>已付款至担保方<{/t}>
        <{case value='3'}>
         <!--普通订单-->
        <{if $order.promotion_type != 'prepare'}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>"><{t}>等待补款<{/t}></a>
        <{/if}>
         <!--预售订单-->
        <{if  $order.promotion_type == 'prepare'}>
        <a href="#"><{t}>等待补款<{/t}></a>
        <{/if}>
        <{switch from=$order.ship_status}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{case value='4'}><{t}>部分退款<{/t}>
        <{switch from=$order.ship_status}>
        <{case value='0'}><{t}>[未发货]<{/t}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{case value='5'}><{t}>已退款<{/t}>
        <{switch from=$order.ship_status}>
        <{case value='0'}><{t}>[未发货]<{/t}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{case}>
         <!--普通订单-->
        <{if $order.promotion_type != 'prepare'}>
			<{if $order.c_status == '0'}>
				<{t}>等待供应商确认库存<{/t}>
			<{elseif $order.c_status == "1"}>
				<{t}>等待客服确认运费<{/t}>
            <{elseif $order.c_status == '5'}>
          <{if $order.payinfo.pay_app_id != '-1'}><a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>"><{/if}>
                <{t}>等待付款(有缺货)<{/t}>
          <{if $order.payinfo.pay_app_id != '-1'}></a>
              	<{if $order.main_client_type == 3 && $order.consignee.kaliningrad != 1 && $order.consignee.RF == 1}>
						<br/>
						<div class="hide">	
							<a class="btn btn-success btn-xs alpha-pay" href="https://pay.qifa.ru?number=<{$order.order_id}>&amount=<{$order.cur_amount|round}>&uType=3&page=<{$smarty.server.PHP_SELF}>">Оплатить заказ</a>
						</div>		
						<div class="input-group" style="padding: 5px 15px;">
							<input type="number" min="0" name="amount"  value="<{$order.cur_amount|round}>" class="form-control input-sm pay-order-amount" style="padding: 3px; height: 22px;"/>
							<span class="input-group-btn">
								<a class="btn btn-success btn-xs alpha-pay pay-order-link"  href="https://pay.qifa.ru?number=<{$order.order_id}>&amount=<{$order.cur_amount|round}>&uType=3&page=<{$smarty.server.PHP_SELF}>">Оплатить</a>
							</span>
						</div><!-- /input-group -->
				<{/if}>
          <{/if}>
			<{else}>
				<{if $order.payinfo.pay_app_id != '-1'}>
					<a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>"><{/if}><{t}>等待付款<{/t}><{if $order.payinfo.pay_app_id != '-1'}></a>
						<{if $order.main_client_type == 3 && $order.consignee.kaliningrad != 1 && $order.consignee.RF == 1}>
						<br/>
						<div class="hide">	
							<a class="btn btn-success btn-xs alpha-pay" href="https://pay.qifa.ru?number=<{$order.order_id}>&amount=<{$order.cur_amount|round}>&uType=3&page=<{$smarty.server.PHP_SELF}>">Оплатить заказ</a>
						</div>		
						<div class="input-group" style="padding: 5px 15px;">
							<input type="number" min="0" name="amount" value="<{$order.cur_amount|round}>" class="form-control input-sm pay-order-amount" style="padding: 3px; height: 22px;"/>
							<span class="input-group-btn">
								<a class="btn btn-success btn-xs alpha-pay pay-order-link" href="https://pay.qifa.ru?number=<{$order.order_id}>&amount=<{$order.cur_amount|round}>&uType=3&page=<{$smarty.server.PHP_SELF}>">Оплатить</a>
							</span>
						</div><!-- /input-group -->
						<{/if}>
				<{/if}>
			<{/if}>
        <{/if}>
        <!--预售订单-->
         <{if $order.promotion_type == 'prepare'}>
          <{if $order.payinfo.pay_app_id != '-1'}><a href="#"><{/if}><{t}>等待付款<{/t}><{if $order.payinfo.pay_app_id != '-1'}></a><{/if}>
        <{/if}>
        <{switch from=$order.ship_status}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{/switch}>
        <{/switch}>
      </td>
        <td class="payments moneyorder" style="border-left: 1px solid #eee;border-bottom: 1px solid #eee;"><{$order.payinfo.pay_app_id|pay_name}></td>
	  <td class="moneyorder" style="border-left: 1px solid #eee;border-bottom: 1px solid #eee;">
	      <{if $order.payinfo.pay_app_id && $order.payinfo.pay_app_id != 'deposit'}>
	      <input type="hidden" name="order_id" value="<{$order.order_id}>">
          <div class="division pic-main" style="margin:0;position:relative">
            <div class="clearfix tc">
              <span class="pic-uploader" id="sdf">
                <{button app="desktop" class="btn-upload" label=$___b2c="添加"|t:'b2c' icon="image_new.gif"}>
              </span>
            </div>

            <div class="pic-area">
              <input type="hidden" name="image_default" value="<$order.image_default_id>" />
              <{include file="site/member/img/gimage_orders.html"}>
            </div>
          </div>
		  <{/if}>
	  </td>
      <td class="actions" style="border-right: 1px solid #eee;border-left: 1px solid #eee;" valign="top" <{if $is_orders}> rowspan="2"<{/if}>>
        <!--普通订单-->
        <{if $order.status == 'active' && ($order.pay_status=='0' || $order.pay_status=='3') && $order.promotion_type != 'prepare' && $order.c_status=='2'}>
          <{if $order.payinfo.pay_app_id != '-1'}>
        <!--<a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>" class="btn btn-import"><span><span><{t}>去付款<{/t}></span></span></a>-->
        <{/if}>
      <{/if}>

      <!--预售订单-->
        <{if $order.status == 'active' && $order.pay_status=='0' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' && $order.prepare.begin_time < $order.prepare.nowtime &&  $order.prepare.nowtime < $order.prepare.end_time}>
          <{if $order.payinfo.pay_app_id != '-1'}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>" class="btn btn-import"><span><span><{t}>付订金<{/t}></span></span></a>
          <{/if}>
        <{/if}>
        <!--预售订单-->
        <{if $order.status == 'active' && $order.pay_status=='3' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' && $order.prepare.begin_time_final < $order.prepare.nowtime &&  $order.prepare.nowtime < $order.prepare.end_time_final}>
          <{if $order.payinfo.pay_app_id != '-1'}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>" class="btn btn-import"><span><span><{t}>付尾款<{/t}></span></span></a>
          <{/if}>
        <{/if}>
        <!--预售订单-->
        <{if $order.status == 'active' && $order.pay_status=='3' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' && $order.prepare.begin_time < $order.prepare.nowtime &&  $order.prepare.nowtime < $order.prepare.begin_time_final}>
          <{if $order.payinfo.pay_app_id != '-1'}>
          <a href="#" class="btn btn-import"><span><span><{t}>等待支付尾款<{/t}></span></span></a>
          <{/if}>
        <{/if}>
		

        <{if $order.status == 'active' && $order.pay_status!='1' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' &&  $order.prepare.nowtime > $order.prepare.end_time_final}>
          <{if $order.payinfo.pay_app_id != '-1'}>
          <span><span><{t}>支付尾款时间已过,请联系管理员进行退款<{/t}></span></span>
          <{/if}>
        <{/if}>


        <i class="separator"></i><a href="<{link app=b2c ctl=site_member act=orderdetail arg0=$order.order_id arg1=$archive}>"><{t}>查看订单<{/t}></a>

        <{if $order.status == 'active' && $order.pay_status == '0' && $order.ship_status == '0' && $order.promotion_type != 'prepare'}>
       <!-- <i class="separator"></i><a class="btn-cancel" href="<{link app=b2c ctl=site_member act=cancel arg0=$order.order_id arg1=$archive}>"><{t}>取消订单<{/t}></a> -->
        <{else}>

        <{if $order.status == 'dead'}>
        <!--<i class="separator"></i>
        <a href="javascript:if(confirm('<{t}>删除以后将不会再看到该订单，是否继续？<{/t}>')) location='<{link app=b2c ctl=site_order act=dodelete arg0=$order.order_id}>'">
          <{t}>删除订单<{/t}></a> -->
        <{/if}>
        <{/if}>
        <i class="separator"></i><a href="<{link app=b2c ctl=site_member act=reAddCart arg0=$order.order_id arg1=$archive}>"><{t}>再次购买<{/t}></a>

        <{if $order.c_status == '2'}>
		   <!-- <i class="separator"></i><a href="<{link app=b2c ctl=site_member act=pay_download arg0=$order.order_id}>" ><{t}>帐单下载<{/t}></a> -->
		
	    <{/if}>
        <!--<{if $order.status == 'active' && $order.c_status == 4}>-->
        <!--<i class="separator"></i><a href="<{link app=b2c ctl=site_member act=confirm arg0=$order.order_id}>"><{t}>订单确认<{/t}></a>-->
    <!--<{/if}>-->
  </td>
</tr>
<tr class="goods-row" width="10%">
  <td colspan="5" style="border-left: 1px solid #eee;">
    <ul class="member-piclist">
      <{if $order.goods_items}>
      <{foreach from=$order.goods_items item=item_goods name=goods_item}>
      <!--goods-->
          <{if $item_goods.product && $item_goods.product.quantity > 0}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_goods.product.name}>&nbsp;<{if $item_goods.product.attr}><{$item_goods.product.attr|spec_desc}><{/if}>&nbsp;<{$item_goods.product.quantity}>">
              <a target="view_frame" href="<{$item_goods.product.link_url}>"><img src="<{$item_goods.product.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_goods.product.name}> <{$item_goods.product.attr}>" data-img-zoom="true"></a>
            </div>
          </li>




          <{/if}>

          <!--adjunct-->
          <{if $item_goods.adjunct_items}>
          <{foreach from=$item_goods.adjunct_items item=item_adjunct name=adjunct_item}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_adjunct.name}><{if $item_adjunct.attr}>&nbsp;<{$item_adjunct.attr}><{/if}>&nbsp;<{$item_adjunct.quantity}>">
              <span class="label-important"><{t}>配<{/t}></span>
              <a href="<{link app=b2c ctl=site_product act=index arg0=$item_adjunct.products.product_id}>"><img src="<{$item_adjunct.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>
            </div>
          </li>
          <{/foreach}>
          <{/if}>

          <!--gift-->
          <{if $item_goods.gift_items}>
          <{foreach from=$item_goods.gift_items item=item_gift name=gift_item}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_gift.name}>&nbsp;<{if $item_gift.attr}><{$item_gift.attr}><{/if}>&nbsp;<{$item_gift.quantity}>">
              <span class="label-important"><{t}>赠<{/t}></span>
              <a href="<{$item_gift.link_url}>"><img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>
            </div>
          </li>
          <{/foreach}>
          <{/if}>
          <{/foreach}>
          <{/if}>
          <!-- gift -->
          <{if $order.order.gift_items}>
          <{foreach from=$order.order.gift_items item=item_gift name=gift_item}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_gift.name}>&nbsp;<{if $item_gift.attr}><{$item_gift.attr}><{/if}>&nbsp;<{$item_gift.quantity}>">
              <span class="label-important"><{t}>赠<{/t}></span>
              <a href="<{$item_gift.link_url}>"><img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>
            </div>
          </li>
          <{/foreach}>
          <{/if}>
          <{if $order.gift.gift_items}>
          <{foreach from=$order.gift.gift_items item=item_gift name=gift_item}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_gift.name}>&nbsp;<{if $item_gift.attr}><{$item_gift.attr}><{/if}>&nbsp;<{$item_gift.quantity}>">
              <span class="label-important"><{t}>赠<{/t}></span>
              <a href="<{$item_gift.link_url}>"><img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>
            </div>
          </li>
          <{/foreach}>
          <{/if}>

          <!-- extends -->
          <{if $order.extends_items}>
          <{foreach from=$order.extends_items item=item_extends name=item_extends}>
          <{$item_extends}>
          <{/foreach}>
          <{/if}>
        </ul>
      </td>
    </tr>
    <tr>
    <td colspan="6" style="height:20px; border-top:1px solid #eee;"></td>
    </tr>
  </tbody>
  <{/foreach}>
  <{else}>
  <tbody class="first">
    <tr class="no-information"><td colspan="6"><{t}>暂无订单<{/t}></td></tr>
  </tbody>
  <{/if}>
</table>

<!-- add by yyj 2015/9/14 start -->
<input type="hidden" id="gEditor-GCat-input" name="cat_id" value="" />
<input type="hidden" id="gEditor-GType-input" name="type_id" value="" />
<input type="hidden" id="gEditor-GId-input" name="goods_id" value="" />
<{script src="moo.min.js" app="site"}>
<{script src="ui.min.js" app="site"}>
<{lang_script src="lang.js" app="desktop"}>	
<script src="<{$res_dir}>/js_mini/moo_min.js" ></script>
<script src="<{$res_dir}>/js_mini/tools_min.js"></script>
<{script src="loader.js" app="desktop"}>
<{script src="coms/uploader.js" app="desktop"}>
<{script src="goodseditor.js" app="b2c"}>
<!-- end -->

<script>
(function() {
    var sess_id = '<{$session_id}>';
    Ex_Loader('uploader',function(){
		if (document.getElements('.swiff-uploader-box')) {
            document.getElements('.swiff-uploader-box').destroy();
        }
      $$('.pic-uploader').each(function(el,j){
	    if (document.getElements('.swiff-uploader-box')) {
            //document.getElements('.swiff-uploader-box').destroy();
        }
        var pic_main = el.getParent('.pic-main');
        var area = pic_main.getElement('.pic-area');
        var pics = pic_main.getElement('.all-pics');
		var order_id = el.getParent('.moneyorder').getElement('input[name=order_id]').value;
        new Swiff.Uploader( {
            allowDuplicates: true,
            verbose: true,
            url:'<{link app=b2c ctl=site_member act=gimage_swf_remote}>?sess_id='+sess_id+'&order_id='+order_id,
            path: '<{$image_dir}>/uploader.swf',
            typeFilter: {
                'Images (*.jpg, *.jpeg, *.gif, *.png)': '*.jpg; *.jpeg; *.gif; *.png'
            },
            fileSizeMax:'<{$IMAGE_MAX_SIZE}>',
            target:el,
            onSelect:function(rs){
                if(rs)
                rs.each(function(v){
                    if(v.size>this.fileSizeMax){
                        Message.error(v.name+'<{t}>\n\n文件超出大小<{/t}>');
                    };
                },this);
            },
            onSelectFail:function(rs){
                rs.each(function(v){
                    if(v.validationError=='sizeLimitMax'){
                        Message.error(v.name+'<{t}>\n\n文件超出大小<{/t}>');
                    };
                });
            },
            onSelectSuccess:function(rs){console.log(rs);
                var PID='up_';
                var _this=this;
                rs.each(function(v,i){
                     new Element('div',{'class':'gpic-box fl','id':PID+j+v.id}).inject(pics);
                });
                this.start();
            },
            onFileOpen:function(e){
                $('up_'+j+e.id).setHTML('<em style="font-size:13px;font-family:Georgia;">0%</em>');
            },
            onFileProgress:function(e){
			    if(e.progress.percentLoaded > 100){
				    e.progress.percentLoaded = 100;
				}
                $('up_'+j+e.id).getElement('em').set('text',e.progress.percentLoaded+'%');
            },
            onFileComplete: function(res){
                if(res.response.error){ 
                    return  new Message.error('<{t}>文件<{/t}>'+res.name+'<{t}>上传失败<{/t}>');
                }
                $('up_'+j+res.id).setHTML(res.response.text);
                if(!$E('.current',area) && $E('.gpic',area)){
                  $E('.gpic',area).onclick();
                }
            }
        });
      });
    });
})();

//删除图片 by yyj
function img_del(obj){
    if(confirm('<{t}>确认删除本图片吗？<{/t}>')){
		var pic_box = obj.getParent('.gpic-box'),picNext=pic_box.getNext('.gpic-box');
		var order_id = obj.getParent('.moneyorder').getElement('input[name=order_id]').value;
		new Request({
			url: '<{link app=b2c ctl=site_member act=del_image}>',
			data: "order_id="+order_id+"&image_id="+obj.get('ident')+"&response_json=true",
			onComplete: function(rs){
				rs = JSON.decode(rs);
				if(rs.success) {
					try{
						if(obj.get('ident')){
						   if($$('#all-pics input[name=image_default]')[0])
						   $$('#all-pics input[name=image_default]')[0].value=obj.get('ident');
						   $('all-pics').eliminate('cururl');
						}
					}catch(e){
					   pic_box.destroy();
					}
					if(picNext)picNext.getElement('.gpic').onclick();
				}else{
				   return Message.error(rs.error);
				}
			}
		}).post();
	}
}

//查看图片路径 by yyj
function view_sourse(act){
    var index = true;
	var dialog = Dialog2.image(act, {
		width:600,
		height:600,
		title:'<{t}>查看图片信息<{/t}>',
		target:'_blank',
		single:true,
		onShow: function() {
			$(document.body).addEvent('click', function() {
			    if(index){
				    index = false;
				}else{
				    dialog.hide();
				}
			});
		},
		onClose: function() {
			$(document.body).removeEvents('click');
			$$('.image-container').removeClass('image-container');
			$$('.mask').removeClass('mask');
		}
	});
}

function pic_view(id,obj){
	var pic_main = $(obj).getParent('.pic-main');
	var area = pic_main.getElement('.pic-area');
	var target = $E('.gpic[image_id='+id+']',area);
	if(target.hasClass('current')){return;}
	var cur,imgdefinput;
	if(cur = $E('.current',area)){
		 cur.removeClass('current');
	 }
	if(imgdefinput = $E('input[name=image_default]',area)){
	   imgdefinput.set('value',id);
	}
	target.addClass('current');
}
</script>

